package cn.tedu.spring6.bean3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class User {
    @Value("张三")
    private String name;
    @Value("30")
    private Integer age;


    //可以写在setter方法中
    /*@Value("李四")
    public void setName(String name) {
        this.name = name;
    }
@Value("30")
    public void setAge(Integer age) {
        this.age = age;
    }*/
/*//也可以写在构造方法中
    private String name;
    private Integer age;
    public User(@Value("赵五") String name,@Value("29") Integer age) {
        this.name = name;
        this.age = age;
    }*/

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
